package com.tron.time;

import java.time.*;
import java.util.Set;

public class TimeStart {
    public static void main(String[] args) throws InterruptedException {
        // 地球自转一圈要 24*60*60 = 86400秒
        // 时间轴 是起点从1970-01-01年午夜开始0，之后没增加一天就加86400秒

        // 时间轴上的一个点
        final Instant now = Instant.now();
        System.out.println(now.getEpochSecond());
        Thread.sleep(1000);
        final Instant end = Instant.now();
        final Duration between = Duration.between(now, end);
        System.out.printf("秒：%d 分钟：%d 小时：%d \n",between.toMillis(),between.toMinutes(),between.toHours());

        // 时区时间
        final Set<String> availableZoneIds = ZoneId.getAvailableZoneIds();
        availableZoneIds.forEach(e->{
            // Asia/Shanghai
            System.out.println(e);
        });
        final ZonedDateTime zonedDateTime = ZonedDateTime.of(LocalDateTime.now(), ZoneId.of("America/Guadeloupe"));
        System.out.println(zonedDateTime);
        final ZoneOffset offset = zonedDateTime.getOffset();
        System.out.println(offset.getId());
    }
}
